/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mac
 * Date: 2022-09-12
 * Time: 18:29
 */
//受查异常
class MyException extends Exception{
    public MyException(String message) {
        super(message);
    }
}
//非受查异常
class MyException2 extends RuntimeException{
    public MyException2(String message) {
        super(message);
    }
}
public class TestDemo3 {
    public static void main(String[] args) throws MyException2{
        int i = 1;
        while (i < 10){
            try{
                throw new MyException2("正在链接网络");
            }catch (MyException2 e){
                e.printStackTrace();
                System.out.println("尝试链接网络" + i + "次......");
                i++;
            }
        }
        System.out.println("终于有网了，程序继续执行");
    }
    public static void func4(int x){
        if (x == 0){
            throw new MyException2("x == 0");
        }
    }
    public static void func3(int x)throws MyException2{
        try {
            if (x == 0){
                throw new MyException2("x == 0");
            }
        } catch (MyException2 e) {
            e.printStackTrace();
        }
    }
    public static void func1(int x){
        try {
            if (x == 0){
                throw new MyException("x == 0");
            }
        } catch (MyException e) {
            e.printStackTrace();
        }
    }
    public static void func2(int x)throws MyException{
        if (x == 0){
            throw new MyException("x == 0");
        }
    }
    public static void main1(String[] args) {
        func4(0);
    }
}
